package com.ysxsoft.wdg.ui.fragment.th;

import android.support.design.widget.TabLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ysxsoft.wdg.R;
import com.ysxsoft.wdg.adapter.th.ThTgAdapter;
import com.ysxsoft.wdg.base.BaseFragment;
import com.ysxsoft.wdg.ui.activity.th.tuan.TuanGoodsDetailActivity;

import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;



public class TuanFragment extends BaseFragment {


    @BindView(R.id.tabLayout)
    TabLayout tabLayout;
    @BindView(R.id.recyclerview)
    RecyclerView recyclerview;

    private ThTgAdapter adapter;

    @Override
    protected int getLayoutId() {
        return R.layout.fm_th;
    }

    @Override
    protected void initData() {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add("");
            tabLayout.addTab(tabLayout.newTab().setText("团购"+i));
        }


        recyclerview.setLayoutManager(new LinearLayoutManager(mContext));
        adapter = new ThTgAdapter(R.layout.item_pt);
        recyclerview.setAdapter(adapter);
        adapter.setNewData(list);

    }

    @Override
    protected void lazyLoadData() {
        super.lazyLoadData();
    }

    @Override
    protected void setListener() {
        tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });


        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                TuanGoodsDetailActivity.start(mContext,"");
            }
        });
    }



}
